/**
 * Created by Administrator on 2016/12/17.
 */

// 仅选择日期
$(".form-date").datetimepicker(
    {
        language:  "zh-CN",
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        format: "yyyy-mm-dd"
    });

/*解析href*/
var str = location.search;
str = str.slice(1).split('&');
var json = {};
for (var i = 0; i < str.length; i++) {
    var a = str[i].split('=');
    json[a[0]] = a[1];
}
//console.log(json);

$(function () {
    /*初始化*/
    init();
});

/*layer弹框效果*/
function ifrLayer (element , url){
    element.on("click", '', function() {
        layer.open({
            type: 2,
            maxmin: false,
            shadeClose: true,
            area : ['100%' , '100%'],
            content:url,
            title :　false
        });
    });
}
function init(){
    $('#workTable').bootstrapTable({
        method : 'get',  //发送方式
        url : `http://192.168.59.3:8082/console/shopping/equprocla?projectCode=${json.projectCode}&shopId=${json.shopId}&pageNum=1&pageSize=10`,
        onLoadSuccess : function () {

        }
    })
}
/*回调函数*/
function responseHandler(res) {

    var needData = {
        rows: res.data.list,
        total: res.data.total
    };

    return needData;
}
/*每页序号*/
function indexFmt(val,row,index){
    return index+1;
}
/*分页器*/
function workTableQuery(params){
    params["pageNum"] = (params.offset / params.limit) + 1;
    params.pageSize = params.limit;

    return params;
}
function handlerFmt(value,row){
    //console.log(row);
    return `<button onclick="getDetail('${row.legalPerson}','${row.categoryId}')"><span class="icon icon-caret-down"></span></button>`
}
function getDetail(code1,code2,code3){
    /*console.log(code1);
     console.log(code2);
     console.log(code3);*/
    layer.open({
        type: 2,
        maxmin: false,
        shadeClose: false,
        closeBtn: 1,
        area : ['100%' , '100%'],
        content:`../platform-detail-ein/platform-detail-ein.html?projectCode=${json.projectCode}&shopId=${json.shopId}&legalPerson=${code1}&categoryId=${code2}`,
        title :　false
    });
}